function Audio()
{
	
	var element = document.createElement("audio");
	var sources = new Array();
	var ready   = false;
	
	var onReady = function()
	{
		ready                = true;
		element.currentTime %= element.duration;
		element.removeEventListener("canplaythrough", onReady);
	}
	
	var autoload = function()
	{
		ready = false;
		element.addEventListener("canplaythrough", onReady);
		element.load();
	}
	
	this.getElement = function()
	{
		return element;
	}
	
	this.appendSources = function()
	{
		var object;
		for (var i = 0; i < arguments.length; i++)
		{
			object = arguments[i];
			if (!(object instanceof Source))
				continue;
			element.appendChild(object.getElement());
			sources.push(object);
		}
		autoload();
	}

	this.clearSources = function()
	{
		for (var i = 0; i < sources.length; i++)
			element.removeChild(sources[i]);
		sources.length = 0;
		autoload();
	}
	
	this.getSource = function(index)
	{
		return sources[index];
	}
	
	this.setSource = function(index, value)
	{
		sources[index] = value;
		autoload();
	}
	
	this.removeSource = function(index)
	{
		var object = sources[index];
		if (!object)
			return;
		element.removeChild(object.getElement());
		sources.splice(index, 1);
		autoload();
	}
	
	this.play = function()
	{
		element.play();
	}
	
	this.pause = function()
	{
		element.pause();
	}
	
	this.stop = function()
	{
		element.currentTime = 0;
		element.pause();
	}
	
	this.getVolume = function()
	{
		return element.volume;
	}
	
	this.setVolume = function(value)
	{
		element.volume = value < 0 ? 0 : value > 1 ? 1 : value;
	}
	
	this.isReady = function()
	{
		return ready;
	}
	
}